package com.mmsj.cli.example;

import picocli.CommandLine;
import picocli.CommandLine.Option;

import java.util.concurrent.Callable;

public class Login implements Callable<Integer> {
    @Option(names = {"-u", "--user"}, description = "用户名", required = true,prompt = "请输入用户名: ")
    String user;

    @Option(names = {"-p", "--password"}, description = "密码",arity = "0..1",interactive = true,prompt = "请输入密码: ")
    String password;

    @Option(names = {"-cp", "--checkPassword"}, description = "检查密码", interactive = true,required = true,prompt = "请再次输入密码: ")
    String checkPassword;

    public Integer call() throws Exception {
        System.out.println("password = " + password);
        System.out.println("checkPassword = " + checkPassword);
        return 0;
    }

    public static void main(String[] args) {
        String[] commandLineArgs = new String[]{"-u", "user123", "-p","xxx","-cp"};
//        待补充反射强制填写命令
        new CommandLine(new Login()).execute(commandLineArgs);
    }
}
